﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CanSWAT.ArcSWAT
{
    partial class SnowHoldingCapacityFrm : Form
    {
        private SortedDictionary<string, LanduseSnowHoldingCapacity> _shcs = null;

        public SnowHoldingCapacityFrm(SortedDictionary<string, LanduseSnowHoldingCapacity> shcs)
        {
            InitializeComponent();

            _shcs = shcs;
        }

        private void SnowHoldingCapacityFrm_Load(object sender, EventArgs e)
        {
            try
            {
                foreach (LanduseSnowHoldingCapacity ls in _shcs.Values)
                    if(ls.IsUsedInFinalHRU) this.listBox1.Items.Add(ls);

                if (this.listBox1.Items.Count > 0)
                    this.listBox1.SelectedIndex = 0;
            }
            catch (System.Exception ee)
            {
                CanSWAT.showInformationWindow(ee.ToString());
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listBox1.SelectedItem != null)
            {
                LanduseSnowHoldingCapacity ls = this.listBox1.SelectedItem as LanduseSnowHoldingCapacity;

                txtShcConTill.DataBindings.Clear();
                txtShcNoTill.DataBindings.Clear();

                txtShcConTill.DataBindings.Add("Text", ls, "ConventionalTill", false, DataSourceUpdateMode.OnPropertyChanged);
                txtShcNoTill.DataBindings.Add("Text", ls, "NoTill", false, DataSourceUpdateMode.OnPropertyChanged);
            }
        }

        private void bSave_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
